package com.gao.instantiating;

import com.gao.instantiating.instancefac.BarBean;
import com.gao.instantiating.staticfac.FooBean;
import com.gao.instantiating.staticfac.StaticFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author GaoXi
 * @date 2022/2/21 11:44
 */
public class Starter {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("three-instantiating.xml");
        //1.构造函数
        NoArgConstruct bean = applicationContext.getBean(NoArgConstruct.class);
        System.out.println(bean);

        //2.静态工厂方法
        FooBean bean1 = applicationContext.getBean(FooBean.class);
        System.out.println(bean1);
        /**
         *静态工厂类是获取不到的，虽然bean标签中的class指定时工厂类
         *StaticFactory bean3 = applicationContext.getBean(StaticFactory.class);
         *System.out.println(bean3);
         */


        //3.实例工厂方法
        BarBean bean2 = applicationContext.getBean(BarBean.class);
        System.out.println(bean2);
    }
}
